package com.mxchip.livestarmobile.mobile.graham;

import android.content.Context;

import com.duobeiyun.paassdk.live.DbyEngine;
import com.videohigh.hxb.roomclient.MeetingSocketClient;

import org.jetbrains.annotations.NotNull;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;

public class SampleSDK implements SDKInterface {

    private static final String TAG = "SampleSDK";

    private static SampleSDK instance;

    @Nullable
    private Context context;

    @Nullable
    private Settings settings;

    @Nullable
    private DbyEngine mDbyEngine;

    private MeetingSocketClient socketClient = new MeetingSocketClient();

    private SampleSDK() {
        super();
    }

    public static synchronized SampleSDK getInstance() {
        if (instance == null) {
            synchronized (SampleSDK.class) {
                if (instance == null) {
                    instance = new SampleSDK();
                }
            }
        }
        return instance;
    }

    public void init(@NonNull Context context, @NonNull Settings settings) {
        this.context = context;
        this.settings = settings;

        // dbyEngine = DbyEngine.createInstance(this.context.getApplicationContext(), settings.getDbyAppKey(), settings.getDbyAppId(), dbyEventHandler);
        // socketClient.addCallbackHandler(meetingSocketCallback);
    }

    public void release() {
        this.context = null;
        this.settings = null;
    }

    public void unsubscribeVideo(@NonNull String uid, @NonNull String streamName) {
        if(mDbyEngine != null) {
            mDbyEngine.muteRemoteVideoStream(uid, streamName, true);
        }
    }

    public void subscribeVideo(@NonNull String uid, @NonNull String streamName) {
        if(mDbyEngine != null) {
            mDbyEngine.muteRemoteVideoStream(uid, streamName, false);
        }
    }

    public void unsubscribeAudio(@NonNull String uid, @NonNull String streamName) {
        if(mDbyEngine != null) {
            mDbyEngine.muteRemoteAudioStream(uid, streamName, true);
        }
    }

    public void subscribeAudio(@NonNull String uid, @NonNull String streamName) {
        if(mDbyEngine != null) {
            mDbyEngine.muteRemoteAudioStream(uid, streamName, false);
        }
    }


    @Override
    public void mgtMuteCamera(@NotNull @Size(min = 1) String[] uids) {

    }

    @Override
    public void mgtMuteAudio(@NotNull @Size(min = 1) String[] uids) {

    }

    @Override
    public void mgtMuteShareContent(@NonNull @Size(min = 1)  String[] uids) {

    }
}
